import React, { Component } from 'react';
import { Link,browserHistory } from 'react-router';
import Lightbox from 'react-image-lightbox';
import {SingleInfo,InfoTitle,InfoImage2,InfoImage3,DateInfo} from '../common/Forminfo';
import { connect } from 'react-redux';
import { IssuingGet } from '../../Redux/Actions/issuingAction';

class Issuing extends Component {
  constructor () {
    super();
  }
  componentWillMount(){
    const opt = {
      orderId:this.props.location.state.orderId,
      profileId:this.props.location.state.profileId
    }
    this.props.dispatch(IssuingGet(this.props.authReducer.user.data.token,opt));
  }

    render(){
        const issuing = this.props.issuingReducer.issuing.data;
        if(issuing){
            return(
                <div className="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
                    <div className="row">
                        <ol className="breadcrumb">
                        <li><a href="#"><span className="glyphicon glyphicon-home"></span></a></li>
                        <li>开证详情</li>
                        </ol>
                    </div>
                    <div className="row">
                        <div className="col-lg-12">
                        <div className="panel panel-default">
                            <div className="panel-heading">
                                开证详情
                                <Link className="pull-right btn btn-primary" style={{marginTop:"6px"}} to={this.props.location.state.backurl}>返回</Link>
                                <Link to={{pathname:"/main/issuingupdate",state:{backurl:this.props.location.state.backurl}}} className="pull-right btn btn-primary" style={{marginTop:"6px",marginRight:"15px"}}>编辑</Link>
                            </div>
                            <div className="panel-body">
                                <div className="form-horizontal">
                                    <InfoTitle title="订单信息"/>
                                    <SingleInfo label="起运港" info={issuing.portOfShipment}/>
                                    <SingleInfo label="银行帐号" info={issuing.bankId}/>
                                    <SingleInfo label="公司电话" info={issuing.companyPhone}/>
                                    <SingleInfo label="公司地址" info={issuing.companyAddress}/>
                                    <SingleInfo label="银行地址" info={issuing.bankAddress}/>
                                    <DateInfo label="预约开票日期" info={issuing.expectedDate}/>

                                    <InfoTitle title="车辆信息"/>
                                    <SingleInfo label="车型" info={issuing.carType}/>
                                    <SingleInfo label="车架号" info={issuing.carFrameNo}/>
                                    <SingleInfo label="发动机号" info={issuing.engineNo}/>
                                    <SingleInfo label="车辆颜色" info={issuing.carColor}/>
                                    <SingleInfo label="排量" info={issuing.deliveryCapacity}/>
                                    <SingleInfo label="座位数" info={issuing.seatNo}/>
                                    <SingleInfo label="用油类型" info={issuing.oilType}/>
                                    <SingleInfo label="轮胎尺寸" info={issuing.tireSize}/>
                                    <InfoImage2 name="车辆照片" src={issuing.carUrl} />
                                    
                                    <InfoTitle title="许可证"/>
                                    <SingleInfo label="是否保税" info={issuing.isBonded == true? "是" : "否"}/>

                                    <InfoTitle title="报文/T款回单"/>
                                    <InfoImage2 name="报文/T款回单照片" src={issuing.BTUrl} />

                                    <InfoTitle title="3C照片"/>
                                    <InfoImage2 name="3C照片" src={issuing.cccUrl}/> 
                                    

                                    <InfoTitle title="车辆手续"/>
                                    <InfoImage3 name="关单照片" src={issuing.shutBillUrl}/> 
                                    <InfoImage3 name="商检照片" src={issuing.commodityUrl}/> 
                                    <InfoImage2 name="一致性" src={issuing.uniformityUrl}/> 
                                    <InfoImage3 name="电子信息单" src={issuing.electronicInfoUrl}/> 
                                    <InfoImage3 name="车辆发票" src={issuing.carInvoiceUrl}/> 
                                    <InfoImage3 name="购置税申请表" src={issuing.purchaseTaxUrl}/> 

                                    <InfoTitle title="发票信息"/>
                                    <DateInfo label="预约开票日期" info={issuing.appointmentMakeInvoiceTime}/>
                                    <InfoImage2 name="开票信息" src={issuing.InvoiceInfoUrl}/> 
                                </div>
                            </div>
                        </div>
                        </div>
                    </div>	
                </div>
                )
        }else{
            return <div></div>
        }
    }
}

export default connect((state) => {
    const { authReducer,issuingReducer } = state;
    return {
        authReducer,issuingReducer
    }
})(Issuing);